package com.zsrt.java.day20161226.wrl.day161226.homework;

import java.util.Scanner;

public class XX {
	
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.println("请输入第一个数字：");
		int number1 = input.nextInt();
		System.out.println("请输入运算符：+ - * / %");
		String flag = input.next();
		System.out.println("请输入第二个数字：");
		int number2 = input.nextInt();
		input.close();
		
		int result = cal01(number1,flag,number2);
		System.out.println(number1+flag+number2+"="+result);
		
	}
	
	
	public static int cal01(int n1,String flag,int n2) {
		int result = 0;
		switch (flag) {
			case "+":	add(n1,n2);		break;
			case "-":	sub(n1,n2);		break;
			case "*":	cheng(n1,n2);	break;
			case "/":	chu(n1,n2);		break;
			case "%":	mo(n1,n2);		break;
			default:	System.out.println("输入有误，请重新输入！");	break;
		}
		return result;
	}
	
	public static void cal02(int n1,String flag,int n2) {
		if("+".equals(flag)){
			add(n1,n2);
		}else if("-".equals(flag)){
			sub(n1,n2);
		}else if("*".equals(flag)){
			cheng(n1,n2);
		}else if("/".equals(flag)){
			chu(n1,n2);
		}else if("%".equals(flag)){
			mo(n1,n2);
		}else{
			System.out.println("输入有误，请重新输入！");
		}
	}
	
	/**
	 * 两数相加
	 * @param x	加数1
	 * @param y	加数2
	 * @return	两数之和
	 */
	public static int add(int x,int y){
		int sum = x+y;
		return sum;
	}
	
	/**
	 * 两数相减
	 * @param x	被减数
	 * @param y	减数
	 * @return	两数之差
	 */
	public static int sub(int x,int y){
		int result = x-y;
		return result;
	}
	
	/**
	 * 两数相乘
	 * @param x	乘数1
	 * @param y	乘数2
	 * @return	两数之积
	 */
	public static int cheng(int x,int y){
		int result = x*y;
		return result;
	}
	
	/**
	 * 两数相除
	 * @param x	被除数
	 * @param y	除数
	 * @return	两数之商
	 */
	public static int chu(int x,int y){
		int result = x/y;
		return result;
	}
	
	/**
	 * 两数求模
	 * @param x	数1
	 * @param y	数2
	 * @return	两数之模
	 */
	public static int mo(int x,int y){
		int result = x%y;
		return result;
	}

}
